<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <title>资讯详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
    <script src="layui/layui.js" type="text/javascript" charset="UTF-8"></script>
    <script src="js/jquery-3.6.3.js"></script>
</head>
<body>

<div class="layui-container" style="width: 80%">
    <div class="layui-row layui-col-space15" style="margin-top:75px;" >
        <div class="layui-col-md4">
            <div class="layui-panel" >
                <div style=" margin: 30px 30px 35px 30px; width: auto; height: 400px; overflow-y: auto;">
                        <ul style="height: 380px">
                            <li id="zp_ul"></li>
                        </ul>
                </div>
            </div>
<!--            嵌套轮播-->
            <div class="layui-row layui-col-space15" style="margin-top:5px;" >
                <div class="layui-col-md12">
                    <div class="layui-panel">
                        <div style="height: 220px;">
                            <div class="layui-fluid" style="width: 90%; height: 200px;">
                                <hr>
                                <div class="layui-carousel" id="test1">
                                    <div carousel-item>
                                        <div><a href=""><img src="img/轮播1.jpg" style="width: 100%; height:auto;" /></a></div>
                                        <div><a href=""><img src="img/轮播2.png" style="width: 100%; height:auto;" /></a></div>
                                        <div><a href=""><img src="img/轮播3.png" style="width: 100%; height:auto;" /></a></div>
                                    </div>
                                </div>
                                <!-- 条目中可以是任意内容，如：<img src=""> -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md8">
            <div class="layui-panel">
                <div style="padding: 30px; height: 800px" th:object="${zixun}">
                    <div style="text-align: center; font-size: 25px" th:text="*{title}"></div>
                    <div class="layui-row" style="color: #999999; font-size: 20px; margin-top: 20px">
                        <span class="layui-col-xs4 layui-col-sm4 layui-col-md4" th:value="*{u_name}" id="uname" th:text="'发布人：' + *{u_name}"></span>
                        <span class="layui-col-xs4 layui-col-sm4 layui-col-md4" th:text="'单位：' + *{department}"></span>
                        <span class="layui-col-xs4 layui-col-sm4 layui-col-md4" th:text="'发布时间：' + *{time}"></span>
                    </div>
                    <div style="width: 90%; margin: auto;">
                        <div style="margin: auto; width: 80%; height: 300px; background-color: #eb7350">
                            <div style="margin-top: 30px">
                                <img th:src="'uploadImages/' + *{photo}" style="width: 100%; height: 300px">
                            </div>
                        </div>

                        <div style="text-indent: 2em; font-size: 20px; line-height: 30px ; margin-top: 30px" th:text="*{content}"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script>

    layui.use(['element'], function () {
        var $ = layui.jquery,
            element = layui.element;
            element.init();

        //当页面一加载时就向后台发送post请求,获取当前用户的姓名
        $(function(){
            $.post("../getusername",function(obj){
                $("#roleName").html(obj.name);
            },"json")
        });
    });

    layui.use('carousel', function(){
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
            elem: '#test1'
            ,width: '100%'    //设置容器宽度
            ,height:'100%'
            ,arrow: 'always'//始终显示箭头
            ,autoplay: 'true',
            //,anim: 'updown' //切换动画方式
        });
    });
</script>

<script>
    function aaa(){
        var uname=document.getElementById('uname').innerText;

        console.log(uname);
        if (uname !== '发布人：admin'){
            return "/QzZpZixun";
        }else{
            return  "/QzAdZixun";
        }
    }


    $(function(){
        var parthurl = aaa();
        $.ajax({
            type: 'get',
            url: window.location.protocol + '//' + window.location.host + parthurl,
            success: function (data) {
                //while (data.size)
                console.log(data);
                var count = 1;
                for (let i = (data.length - 1); i >= 0; i--) {
                    var zid = data[i].id;
                    console.log(zid);
                    $('#zp_ul').append("<li style='padding-top:10px; font-size: 15px;'>" + "<span class='layui-col-md9'>" +
                        "<i id="+ zid + " class='layui-icon layui-icon-triangle-r'></i>" + "&nbsp;<a href='/zixunDetail?id="
                        +zid+"'>" + data[i].title + "</a></span>" +
                        "<span class='layui-col-md3'>" + data[i].time + "</span></li>" + "<hr>");
                    count++;
                }
            },
            error: function () {
                var txt3=document.createElement("p");  // 以 DOM 创建新元素
                txt3.innerHTML="数据加载异常！";
                $("#zp_ul").append(txt3);
            }
        });
    })
</script>
<script src="js/nav.js"></script>
</body>
</html>